package com.demo.writer_;

import java.io.*;

/**
 * @author gy
 * @date 2022/4/5
 */
public class BufferedWriter01 {
    public static void main(String[] args) throws IOException {

        String fileName = "f:\\20220403\\BufferedWriter01.txt";
//        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName));// 覆盖方式写入
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName,true)); // 追加方式写入
        String s = "hello,bufferWriter";
        bufferedWriter.write(s);
        bufferedWriter.newLine();// 根据系统添加一个换行符
        bufferedWriter.write(s);
        bufferedWriter.newLine();
        bufferedWriter.write(s);
        bufferedWriter.newLine();
        bufferedWriter.write(s);
        bufferedWriter.newLine();


        // 最后一定要关闭流，底层调用的是  FileReader.close()
        bufferedWriter.close();
    }
}
